﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Threading;

namespace Ex9.FileSystemWatcherTest
{
    class FileSystemWatcherTest
    {
        static void Main(string[] args1)
        {

            FileSystemWatcher watcher = new FileSystemWatcher();
            watcher.Path = @"..\\..\\";
            watcher.NotifyFilter = NotifyFilters.Size | NotifyFilters.LastWrite
               | NotifyFilters.FileName | NotifyFilters.DirectoryName;
            watcher.Filter = "*.txt";
            watcher.NotifyFilter = NotifyFilters.Size;

            watcher.Changed += new FileSystemEventHandler(OnChanged);

            watcher.EnableRaisingEvents = true;

            Console.WriteLine("Press \'q\' to quit the sample.");
            while (Console.Read() != 'q') ;

        }
        private static void OnChanged(object source, FileSystemEventArgs e)
        {
            Console.WriteLine(File.ReadAllText(e.FullPath));
        }
    }
}
